package com.example.scenictourback.dto;

import com.example.scenictourback.entity.ScenicArea;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;

@Data
public class ScenicAreaDTO {
    
    private Integer id;
    private String name;
    private String description;
    private String address;
    private String openTime;
    private BigDecimal ticketPrice;
    private Integer status;
    
    // 扩展字段，用于展示景点列表
    private List<ScenicSpotDTO> spots;
    
    // 静态方法，将实体对象转为DTO对象
    public static ScenicAreaDTO fromEntity(ScenicArea scenicArea) {
        ScenicAreaDTO dto = new ScenicAreaDTO();
        dto.setId(scenicArea.getId());
        dto.setName(scenicArea.getName());
        dto.setDescription(scenicArea.getDescription());
        dto.setAddress(scenicArea.getAddress());
        dto.setOpenTime(scenicArea.getOpenTime());
        dto.setTicketPrice(scenicArea.getTicketPrice());
        dto.setStatus(scenicArea.getStatus());
        return dto;
    }
    
    // 静态方法，将实体列表转为DTO列表
    public static List<ScenicAreaDTO> fromEntities(List<ScenicArea> scenicAreas) {
        return scenicAreas.stream()
                .map(ScenicAreaDTO::fromEntity)
                .collect(Collectors.toList());
    }
} 